/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.feignimpl.trade;

import com.enation.app.javashop.client.trade.OrderClient;
import com.enation.app.javashop.core.client.fallback.trade.OrderClientFallbackFactory;
import com.enation.app.javashop.core.handler.FeignConfiguration;
import com.enation.app.javashop.model.security.ScanModuleDTO;
import com.enation.app.javashop.model.security.ScanResult;
import com.enation.app.javashop.model.trade.cart.dos.OrderPermission;
import com.enation.app.javashop.model.trade.order.dos.OrderDO;
import com.enation.app.javashop.model.trade.order.dos.OrderItemsDO;
import com.enation.app.javashop.model.trade.order.dto.OrderDetailDTO;
import com.enation.app.javashop.model.trade.order.enums.CommentStatusEnum;
import com.enation.app.javashop.model.trade.order.enums.OrderStatusEnum;
import com.enation.app.javashop.model.trade.order.vo.DeliveryVO;
import com.enation.app.javashop.model.trade.order.vo.OrderDetailVO;
import com.enation.app.javashop.model.trade.order.vo.OrderStatusNumVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 订单查询Feign
 *
 * @author Snow create in 2018/8/6
 * @version v2.0
 * @since v7.0.0
 */
@FeignClient(name = "trade-service", fallbackFactory = OrderClientFallbackFactory.class,configuration = {FeignConfiguration.class})
public interface OrderClientFeignImpl extends OrderClient {

    /**
     * 读取一个订单详细<br/>
     *
     * @param orderSn 订单编号 必传
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/{order_sn}/detail", method = RequestMethod.GET)
    OrderDetailVO getOrderVO(@PathVariable("order_sn") String orderSn);


    /**
     * 读取一个订单详细<br/>
     *
     * @param orderSn 订单编号 必传
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/{order_sn}", method = RequestMethod.GET)
    OrderDetailDTO getModel(@PathVariable("order_sn") String orderSn);


    /**
     * 更改订单评论状态
     *
     * @param orderSn
     * @param statusEnum
     */
    @Override
    @RequestMapping(value = "/client/orders/{order_sn}/comment-status", method = RequestMethod.POST)
    void updateOrderCommentStatus(@PathVariable("order_sn") String orderSn, @RequestParam("status_enum") String statusEnum);


    /**
     * 根据交易编号查询订单项
     *
     * @param tradeSn
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/{trade_sn}/order-sku-list", method = RequestMethod.GET)
    List<OrderDetailDTO> getOrderByTradeSn(@PathVariable("trade_sn") String tradeSn);


    /**
     * 为某个订单的付款
     *
     * @param orderSn
     * @param price
     * @param returnTradeNo
     * @param permission
     */
    @Override
    @RequestMapping(value = "/client/orders/{order_sn}/pay", method = RequestMethod.POST)
    void payOrder(@PathVariable("order_sn") String orderSn, @RequestParam("price") Double price, @RequestParam("return_trade_no") String returnTradeNo, @RequestParam("permission") String permission);


    /**
     * 根据会员id读取我的订单数量
     *
     * @param memberId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/{member_id}/order-num", method = RequestMethod.GET)
    Integer getOrderNumByMemberID(@PathVariable("member_id") Long memberId);

    /**
     * 根据会员id读取我的(评论状态)订单数量
     *
     * @param memberId
     * @param commentStatus 评论状态
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/{member_id}/order-comment-num", method = RequestMethod.GET)
    Integer getOrderCommentNumByMemberID(@PathVariable("member_id") Long memberId, @RequestParam("comment_status") String commentStatus);


    /**
     * 读取订单状态的订单数
     *
     * @param memberId
     * @param sellerId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/order-status-num", method = RequestMethod.GET)
    OrderStatusNumVO getOrderStatusNum(@RequestParam(value = "member_id", required = false) Long memberId, @RequestParam(value = "seller_id", required = false) Long sellerId);


    /**
     * 更新订单状态
     *
     * @param sn          订单号
     * @param orderStatus 订单状态
     * @return 是否更新成功
     */
    @Override
    @RequestMapping(value = "/client/orders/{sn}/order-status", method = RequestMethod.POST)
    boolean updateOrderStatus(@PathVariable("sn") String sn, @RequestParam("order-status") OrderStatusEnum orderStatus);

    /**
     * 更新交易状态
     *
     * @param sn          交易sn
     * @param orderStatus 交易状态
     * @return 是否更新成功
     */
    @Override
    @RequestMapping(value = "/client/orders/{sn}/trade-status", method = RequestMethod.POST)
    boolean updateTradeStatus(@PathVariable("sn") String sn, @RequestParam("order-status") OrderStatusEnum orderStatus);


    /**
     * 更新订单项可退款金额
     * @param orderDO
     */
    @Override
    @RequestMapping(value = "/client/orders/item-refund-price", method = RequestMethod.POST)
    void addOrderItemRefundPrice(@RequestBody OrderDO orderDO);

    /**
     * 更新订单项评论状态
     * @param orderSn
     * @param goodsId
     * @param commentStatus
     */
    @Override
    @RequestMapping(value = "/client/orders/update-comment-status", method = RequestMethod.POST)
    void updateItemsCommentStatus(@RequestParam("order_sn") String orderSn, @RequestParam("goods_id")Long goodsId, @RequestParam("comment_status") CommentStatusEnum commentStatus);

    /**
     * 获取某订单的订单项
     *
     * @param orderSn
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/order-items", method = RequestMethod.GET)
    List<OrderItemsDO> orderItems(@RequestParam("order_sn")String orderSn);

    /**
     * 根据订单编号读取一个订单详细
     * @param orderSn
     * @return
     */
    @Override
    @RequestMapping(value = "/client/orders/{order_sn}/orderdo", method = RequestMethod.GET)
    OrderDO getOrder(@PathVariable("order_sn") String orderSn);

    /**
     * 发货
     *
     * @param deliveryVO 运单</br>
     * @param permission 需要检测的订单权限
     */
    @Override
    @RequestMapping(value = "/client/orders/ship", method = RequestMethod.POST)
    void ship(@RequestBody DeliveryVO deliveryVO, @RequestParam("permission") OrderPermission permission);

    @Override
    @GetMapping("/client/orders/by-goods/{goods_id}")
    List<OrderDO> listOrderByGoods(@PathVariable("goods_id") Long goodsId, @RequestParam("member_id") Long memberId,@RequestParam("month") Integer month);

    /**
     * 获取订单商品信息
     *
     * @param orderSn 单号</br>
     */
    @Override
    @GetMapping("/client/orders/promotion-typeand-num")
    List<Map> getItemsPromotionTypeandNum(@RequestParam("order_sn") String  orderSn);

    /**
     * 根据订单号集合，查询订单集合
     * @param orderSnList
     * @return
     */
    @Override
    @GetMapping("/client/orders/by-sns")
    List<OrderDO> queryOrderList(@RequestBody List<String> orderSnList);

    /**
     * 订单签名数据扫描
     * @return
     */
    @Override
    @PostMapping("/client/orders/scan")
    ScanResult scanModule(@RequestBody ScanModuleDTO scanModuleDTO);

    /**
     * 订单数据重新签名
     */
    @Override
    @GetMapping("/client/orders/resign")
    void reSign();

    /**
     * 修复订单数据
     * @param orderId
     */
    @Override
    @GetMapping("/client/orders/repair/{order_id}")
    void repair(@PathVariable("order_id")Long orderId);
}
